package com.yoga.manager.beanUtil;

import com.yoga.common.bo.TeacherBO;
import com.yoga.dao.domain.TeacherDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类TeacherBeanUtil.java的实现描述：工具类
 * 
 * @Author hdx
 * @Date 2020年09月24日
 */
public class TeacherBeanUtil {

    private TeacherBeanUtil(){
    }

    public static TeacherDO teacherBOToDO(TeacherBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        TeacherDO targetObj = new TeacherDO();
        targetObj.setId(srcObj.getTeacherId());//id
        targetObj.setTeacherName(srcObj.getTeacherName());//老师昵称
        targetObj.setRealName(srcObj.getRealName());//真实姓名
        targetObj.setPhone(srcObj.getPhone());//联系电话
        targetObj.setTeacherRemark(srcObj.getTeacherRemark());//老师简介
        targetObj.setTeacherPhoto(srcObj.getTeacherPhoto());//老师照片
        targetObj.setRemark(srcObj.getRemark());//备注
        targetObj.setDeleteMark(srcObj.getDeleteMark());//deleteMark
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        targetObj.setTeacherImg(srcObj.getTeacherImg());

        return targetObj;
    }

    public static TeacherBO teacherDOToBO(TeacherDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        TeacherBO targetObj = new TeacherBO();
        targetObj.setTeacherId(srcObj.getId());//id
        targetObj.setTeacherName(srcObj.getTeacherName());//老师昵称
        targetObj.setRealName(srcObj.getRealName());//真实姓名
        targetObj.setPhone(srcObj.getPhone());//联系电话
        targetObj.setTeacherRemark(srcObj.getTeacherRemark());//老师简介
        targetObj.setTeacherPhoto(srcObj.getTeacherPhoto());//老师照片
        targetObj.setRemark(srcObj.getRemark());//备注
        targetObj.setDeleteMark(srcObj.getDeleteMark());//deleteMark
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        targetObj.setTeacherImg(srcObj.getTeacherImg());

        return targetObj;
    }

    public static List<TeacherBO> doList2BOList(List<TeacherDO> doList) {
        List<TeacherBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(teacherDO -> boList.add(TeacherBeanUtil.teacherDOToBO(teacherDO)));
        return boList;
    }
}